<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
     
        // window.onload=function(){
        //     const table=document.querySelector('#table-wrapper')
        // const btn=document.querySelector('.btn')
        // btn.addEventListener('click',function(){
        //     const temp=document.body.innerHTML
        //     document.body.innerHTML=table.innerHTML
        //     console.log(table.innerHTML)
        //     window.print();
        //     window.location.reload();
        // })
        // }
        window.onload=function(){
            const fra=document.querySelector('#fra')
        const btn=document.querySelector('.btn')
        btn.addEventListener('click',function(){
           
            fra.contentWindow.print();
           
          
            
        })
        }
       
    </script>
    <style>
           #fra{
         min-height: 800px;   
        }
    </style>

</head>
<body>
    　<iframe id="fra" name="fra" src="printData.html" frameborder=0 height=100% width=100%>
    </iframe>
 
    <button class="btn">iframe打印</button>
  
</body>
</html>